function Lbeam2
clc
% close all
addpath('../');
addpath('../../');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% read mesh
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
projDir = '/home/hbui/kratos_janosch';

%structure mesh, coarse mesh
% projName = 'Lbeam.gid';
% fn = [projDir '/' projName '/' 'Lbeam.msh'];
% du = -1; lambda = [0.63 linspace(0.64,4,11)]; %data set 1

% mesh3 data, fine mesh at crack zone
% projName = 'Lbeam3.gid';
% fn = [projDir '/' projName '/' 'mesh3.msh'];
% du = -1; lambda = [0.3 linspace(0.33,1,3)]; %data set 1

%mesh 2 data
% projName = 'Lbeam2.gid';
% fn = [projDir '/' projName '/' 'mesh2.msh'];
% %du = -1; lambda = [0.77 linspace(0.775,6,30)]; %data set 1
% du = -1; lambda = [0.77 0.775:0.05:2]; %data set 2
% du = -1; lambda = [0.77 0.775:0.01:2]; %data set 3

%mesh 1 data
% projName = 'Lbeam2.gid';
% fn = [projDir '/' projName '/' 'mesh1.msh'];
% % du = -1; lambda = [0.5 linspace(0.55,2.3,20)];%data set 1
% %du = -1; lambda = [0.5 0.55:0.1:1.5];%data set 1
% du = -1; lambda = 0.77; dlambda = 0.05; nt = 30; %data set 3 for adaptive strategy

%mesh from gmsh
fn = ['/home/hbui/kratos_janosch/Lbeam2.gmsh/Lbeam2.msh'];
%du = -1; lambda = [0.33 0.34:0.1:4];% dataset 1
%du = -1; lambda = [0.33 0.34:0.1:0.71 0.71:0.005:0.73];% dataset 1
du = -1; lambda = 0.33; dlambda = 0.05; nt = 10; %data set 3 for adaptive strategy

% mg = fem2.gid.GidMeshGenerator(fn);
mg = fem2.GmshMeshGenerator(fn);

mesh = mg.getMesh(2);
mesh.setNumberOfFields(2);
for i=1:mesh.countNodes()
    mesh.getNode(i-1).setId(i);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% conditions
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
meshUtil = fem2.MeshUtilities(mesh);
c1 = fem2.Constraint([0 0]);
c2 = fem2.Constraint([1 0]);
c2.setValue(1,du);
mesh.setConstraint(c1,meshUtil.seekNodesOnSurface(0,1,0));
meshUtil.seekNode([1 -0.5]).setConstraint(c2);
% plotMesh(mesh,{'trimesh','conditions'});
% return
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% element declaration
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
M = fem2.Model(mesh);
nf = mesh.countFaces();
E = 2;
nu = 0.3;
H = -1;
ft = 0.91;
C = C_plane_stress(E,nu);
for i=1:nf
    e = fem2.MatlabStructuralElement(mesh.getFace(i-1));
    M.addElement(e);
    %create struct to contain element state variables
    es = createElementContainer(C,H,ft);
    elements(i) = es;
end
%deactivate and activate elements
for i=1:nf
    c = computeFaceCenter(mesh.getFace(i-1));
    if (c(1)>=0 && c(1)<=0.6 && c(2)>=-0.6 && c(2)<=-0.4)
        elements(i).isActivated = 1;
    else
        elements(i).isActivated = 0;
    end
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% solve
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% postProcessInfo.infoList = {'check sigma1','crack opening Linder'};
% postProcessInfo.infoParam = {[],[]};

postProcessInfo.infoList = {'crack opening Linder'};
postProcessInfo.infoParam = {[]};

% [elements,output] = solving_strategy_static_2(elements,M,...
%     lambda,50,1e-6,postProcessInfo);

[elements,output] = solving_strategy_static_4(elements,M,...
    lambda,dlambda,nt,50,1e-6,postProcessInfo);

plotMeshWithCrack(M,elements,{'trimesh','conditions'});
%plotDeformedMesh(mesh,1);

rmpath('../');
rmpath('../../');

